using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using LeadTracker.EFCodeFirst.Entities;

namespace LeadTracker.EFCodeFirst.Mapping
{
	public class EditorMap : EntityTypeConfiguration<Editor>
	{
		public EditorMap()
		{
			// Primary Key
			this.HasKey(t => t.EditorKey);

			// Properties
			this.Property(t => t.UserName)
				.IsRequired()
				.HasMaxLength(50);
				
			this.Property(t => t.FirstName)
				.HasMaxLength(50);
				
			this.Property(t => t.LastName)
				.HasMaxLength(50);
				
			this.Property(t => t.EmailAddress)
				.IsRequired()
				.HasMaxLength(254);
				
			this.Property(t => t.PasswordSalt)
				.IsRequired();
				
			this.Property(t => t.PasswordHash)
				.IsRequired();
				
			// Table & Column Mappings
			this.ToTable("Editor");
			this.Property(t => t.EditorKey).HasColumnName("EditorKey");
			this.Property(t => t.UserName).HasColumnName("UserName");
			this.Property(t => t.FirstName).HasColumnName("FirstName");
			this.Property(t => t.LastName).HasColumnName("LastName");
			this.Property(t => t.EmailAddress).HasColumnName("EmailAddress");
			this.Property(t => t.PasswordSalt).HasColumnName("PasswordSalt");
			this.Property(t => t.PasswordHash).HasColumnName("PasswordHash");
			this.Property(t => t.IsEnabled).HasColumnName("IsEnabled");
		}
	}
}

